﻿@model List<DeliveryWebSite.Models.OrderForm>

@{
    ViewBag.Title = "NewOrders";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>NewOrders</h2>
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('#divNowTime').text((new Date()).toLocaleDateString() + " " + (new Date()).toLocaleTimeString());
        setInterval(function () {
            window.location.reload(); 
        },5000);
    });


  @*  $(function () {
        var reg=/<table>[\s\S]*?<\/table>/i;
        setInterval(function () {
            $.ajax({
                url: '@Url.Action("NewOrders", "Order")',
                type: "POST",
                cache: false,
                success: function (result) {
                   // var html = reg.exec(result);
                    $("#partialContainer").text(result)
                    $('#divNowTime').text((new Date()).toLocaleDateString() + " " + (new Date()).toLocaleTimeString());
                }
            });
        }, 2000);
    });*@

</script>
<div id="divNowTime" style="text-align: right"></div>
<div id="partialContainer">
 <table>
        <tr>
            <td>OrderFormNumber</td>
            <td>User Name</td>
            <td>Phone</td>
            @* <td>TotalAmount</td>*@
            <td>CreateTime</td>
            <td>Address</td>
            <td>Action</td>
        </tr>

        @foreach (var order in Model)
        {
            <tr>
                <td>@order.OrderFormNumber</td>
                <td>@order.Students.name</td>
                <td>@order.Students.phoneNumber</td>
                @* <td>@order.Amount.Value.ToString("0.00")</td>*@
                <td>@order.CreateTime</td>
                <td>@order.Address.Address_Info</td>
                <td>@Html.ActionLink("Shipped", "UpdateOrderStatus", new { orderNumber = @order.OrderFormNumber, status = (int)DeliveryWebSite.Controllers.OrderStatus.waitingReceipt }, new { onclick = "return confirm('Are you sure you want to ship this order?');" })
                    /@Html.ActionLink("Cancelled", "UpdateOrderStatus", new { orderNumber = @order.OrderFormNumber, status = (int)DeliveryWebSite.Controllers.OrderStatus.Cancelled }, new { onclick = "return confirm('Are you sure you want to cancelled this order?');" })
                </td>
            </tr>
        }
    </table>
</div>
